package com.zhy.learning.demo.domain;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import java.util.Map;

public class C implements ApplicationContextAware {

    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    public ApplicationContext getApplicationContext() {
        return applicationContext;
    }

    public static void main(String[] args) {
//        C c = new C();
//        Map<String, Object> beansWithAnnotationMap = c.getApplicationContext().getBeansWithAnnotation(Job.class);
//        A a = (A) beansWithAnnotationMap.get("b");
//        a.fly("A");
        B b = new B();
        b.fly("B");
    }
}
